# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: 02-线程test.py
"""
import threading
import time


def target(second):
    print(f'Threading {threading.current_thread().name} is running')
    print(f'Threading {threading.current_thread().name} sleep {second}s')
    time.sleep(second)
    print(f'Threading {threading.current_thread().name} is ended')

print(f'Threading {threading.current_thread().name} is running')
for i in [1, 5]:
    thread = threading.Thread(target=target, args=[i])
    thread.start()
print(f'Threading {threading.current_thread().name} is ended')


def target1(second):
    print(f'Threading {threading.current_thread().name} is running')
    print(f'Threading {threading.current_thread().name} sleep {second}s')
    time.sleep(second)
    print(f'Threading {threading.current_thread().name} is ended')
print(f'Threading {threading.current_thread().name} is running')

t = []
for i in [1, 5]:
    thread = threading.Thread(target=target1, args=[i])
    t.append(thread)
    thread.start()
for i in t:
    i.join()
print(f'Threading {threading.current_thread().name} is ended')

# 子线程结束在主线程前面
